﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mail;
using System.Net.Mail;
using System.Web;

namespace Socialnetworking.globalclass
{
    public class Sendemail
    {
        SmtpClient client = new SmtpClient();
        System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

        System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("nishantbcaproject@gmail.com", "bcaproject");
       
        
        
        public void sendemail(string sendto, string subject, string body)
        {
            try
            {
                client.Host = "smtp.gmail.com";
                client.Port = 587;
                client.UseDefaultCredentials = false;
                client.Credentials = credentials;
                client.EnableSsl = false;
                // convert strings to mail address

                MailAddress to = new MailAddress(sendto);
                MailAddress from = new MailAddress("nishantbcaproject@gmail.com");

                //
                msg.Subject = subject;
                msg.Body = body;
                msg.To.Add(to);
                msg.From = from;

                client.Send(msg);

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }


    }

   
}